

public class LinkedChance {
    public static void main(String[] args) {
        ListNode head = new ListNode(1);
        head.next = new ListNode(2);
        head.next.next = new ListNode(3);
        head.next.next.next = new ListNode(4);
        System.out.println(swapPairs(head));
    }
    public static ListNode swapPairs(ListNode head) {
        if(head.next == null || head== null){
            return head;
        }
        ListNode newHead = head.next;
        head.next = swapPairs(newHead.next);
        newHead.next = head;
        return newHead;
    }
}
class ListNode {
    private int val;
    ListNode next;
    public ListNode(int val) {
        this.val = val;
    }


}
